// Register a global custom directive called v-focus-next-on-enter
import Vue from 'vue';

Vue.directive('focusNextOnEnter', {
    bind: function(el, {
        value
    }, vnode) {
        el.addEventListener('keyup', (ev) => {
            if (ev.keyCode === 13) {
                let nextInput = vnode.context.$refs[value]
                if (nextInput && typeof nextInput.focus === 'function') {
                    nextInput.focus()
                    nextInput.select()
                }
            }
        })
    }
})